<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>基于Jquery的轻量级bootstrap检验插件</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
    <h2 style="text-align:center;">基于Jquery的轻量级bootstrap检验插件</h2>
    <br><br>
    <div class="row form-horizontal">
    	<div class="form-group">
    	  <label class="col-sm-2 control-label form-label">名    称:</label>
    	  <div class="col-sm-8">
    	    <input type="text" class="form-control" id="card_name">
    	  </div>
    	</div>
    	<div class="form-group">
    	  <label class="col-sm-2 control-label form-label">手机号:</label>
    	  <div class="col-sm-8">
    	    <input type="text" class="form-control" id="card_name1">
    	  </div>
    	</div>
    	<div class="form-group">
    	  <label class="col-sm-2 control-label form-label">邮    箱:</label>
    	  <div class="col-sm-8">
    	    <input type="text" class="form-control" id="card_name2">
    	  </div>
    	</div>
    	<div class="form-group">
    	  <label class="col-sm-2 control-label form-label">其    他:</label>
    	  <div class="col-sm-8">
    	    <input type="text" class="form-control" id="card_name3">
    	  </div>
    	</div>    	
    </div> 
    <div class="row">
    	<div class="form-group btn-group col-md-offset-4">
    		<button class="btn btn-success" onclick="toValidate()">提    交</button>
    	</div>
    </div>

</body>
<script src="js/jquery-1.10.2.js"></script>
<script src="js/validate.js"></script>
<script>
	function toValidate(){
		var val = new validate({
			/*rules里面是检验规则，
			*key为需要检验的input的id,
			*value为此input对应的检验规则
			*/
			rules:{
				card_name:"notEmpty",   
				card_name1:"mobile",
				card_name2:"email",
				card_name3:"notEmpty"
			},
			/*submitFun里面为检验成功后要执行的方法*/
			submitFun:function(){
				toSubmit();
			}
		})
	}
	function toSubmit(){
		alert("验证通过，提交啦 ！！！")
	}
</script>
</html>